package server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import model.Kunde;

/**
 * @author Safran/Daniel
 * Erzeugt einen multithread Server-Socket
 */
public class Server {
	
	private final ServerSocket SERVER;
	private final static int PORT = 5550;
    
	public Server() throws IOException{
		SERVER = new ServerSocket(PORT);
	}
	
	/**
	 * Server Starten
	 */
	private void startServer(){
		while(true){
			Socket socket = null;
			System.out.println("Server wartet auf Client Connection...");	
			try{
				socket = SERVER.accept();
				System.out.println("Verbindung mit Client hergestellt...");
				
				new Thread(new ServerWorker(socket, "Multithreaded Server")).start();
			}
			catch(IOException e){
				e.printStackTrace();
			}
		}
	}
	
	/**
	 * Main
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException{
		Kunde kunde = null;
	    Server server = new Server();
	    server.startServer();
	}  
}
